function regHandler() {



    let telEl = $(".tel")
    let pwdEl = $(".pwd")
    let nickNameEl = $(".nickName")
    let telErr = $(".telErr")
    let pwdlErr = $(".pwdlErr")
    let agin = $(".agin")
    let aginErr = $(".aginErr")
    let yanzhengEl = $(".yanzheng")
    let duizhaoEl = $(".duizhao")
    let sureEl = $(".sure")
    let loginEl = $(".login_btn")
    let nickErr = $('.nickErr')
    let TestTel = /^1[3|4|5|7|8][0-9]{9}$/
    let Testpwd = /^(?!bai[0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/
    let telFlag = false;
    let telFlag1 = false; //昵称
    let telFlag2 = false;
    let telFlag3 = false;
    let telFlag4 = false;
    let telFlag5 = false;


    telEl.on('blur', function() {
        // console.log(1);
        let tell = telEl.val()
        TestTel.test(tell);
        // console.log(TestTel.test(tel));
        if (TestTel.test(tell)) {
            telFlag = true;
            telErr.html('')
        } else {
            telErr.html('<div>手机号错误</div>')
            telFlag = false;
        }
    })

    pwdEl.on('blur ', function() {
        let pwdd = pwdEl.val()
        Testpwd.test(pwdd)
        if (Testpwd.test(pwdd)) {
            telFlag2 = true;
            pwdlErr.html('')
        } else {
            pwdlErr.html('<div>密码错误</div>')
            telFlag2 = false;
        }
    })

    agin.on('blur', function() {
        let aginpwd = agin.val()
        if (aginpwd === pwdEl.val()) {
            telFlag3 = true;
            aginErr.html('')
        } else if (aginpwd != pwdEl.val()) {
            aginErr.html('<div>和新密码不一致，请重新输入</div>')
            telFlag3 = false;
        } else if (aginpwd = '') {
            aginErr.html('<div>请再次输入密码</div>')
            telFlag3 = false;
        }
    })

    // 昵称
    nickNameEl.on('blur', function() {
        let nickName = nickNameEl.val()
        if (!nickName == '') {
            telFlag1 = true;
            nickErr.html('')
        } else {
            nickErr.html("<div>请输入昵称！</div>")
            telFlag1 = false;
        }

    })
    $('.yanzheng').on('blur', function() {
        let yanzhengnumber = $('.yanzheng').val()
        console.log(yanzhengnumber);
        var str = "C8SZ"
        if (yanzhengnumber === str) {
            $('.ico ').addClass('y_suc')
            $('.ico ').removeClass('y_err')

            telFlag4 = true
        } else {
            $('.ico ').addClass('y_err')
            $('.ico ').removeClass('y_suc')
            telFlag4 = false
        }
    })

    $('.sure').click(function() {
        if ($(this).prop("checked")) {
            $('.check').html('')
            telFlag5 = true
        } else {
            $('.check').html('<div>请勾选我同意</div>')
            telFlag5 = false
        }
    })





    function regg() {

        let pw = $(".pwd").val()
        let tel = $(".tel").val()
        let name = $(".nickName").val()
        console.log(pw, tel, name);
        console.log(telFlag, telFlag1, telFlag2, telFlag3, telFlag4, telFlag5);
        if (!(telFlag && telFlag1 && telFlag2 && telFlag3 && telFlag4 && telFlag5)) {
            return;
        }
        console.log('通过');
        $.ajax({
            type: 'get',
            url: 'http://localhost:3000/register/reg',
            data: {
                name: name,
                tel: tel,
                pw: pw
            },
            dataType: 'json',
            success: function(data) {
                if (data.code) {
                    alert('注册成功')
                        // setTimeout(() => {
                        //     location.href = ''
                        // }, 3000)
                } else {
                    alert('此用户已注册')
                }
            }
        })
    }
    $('.regis').on('click', regg)
}



regHandler()